package com.example.bingobox.utils;

import java.util.Calendar;
import android.icu.util.ChineseCalendar;

public class LunarCalendar {
    private static final String[] WEEK_DAYS = {"周日", "周一", "周二", "周三", "周四", "周五", "周六"};
    private static final String[] CHINESE_MONTHS = {"正", "二", "三", "四", "五", "六", "七", "八", "九", "十", "冬", "腊"};
    private static final String[] CHINESE_DAYS = {
            "初一", "初二", "初三", "初四", "初五", "初六", "初七", "初八", "初九", "初十",
            "十一", "十二", "十三", "十四", "十五", "十六", "十七", "十八", "十九", "二十",
            "廿一", "廿二", "廿三", "廿四", "廿五", "廿六", "廿七", "廿八", "廿九", "三十"
    };

    public static String getLunarDate(Calendar calendar) {
        ChineseCalendar lunar = new ChineseCalendar();
        lunar.setTimeInMillis(calendar.getTimeInMillis());
        
        int month = lunar.get(ChineseCalendar.MONTH) + 1;
        int day = lunar.get(ChineseCalendar.DAY_OF_MONTH);
        boolean isLeapMonth = lunar.get(ChineseCalendar.IS_LEAP_MONTH) == 1;
        
        String monthStr = CHINESE_MONTHS[month - 1] + "月";
        if (isLeapMonth) {
            monthStr = "闰" + monthStr;
        }
        
        return monthStr + CHINESE_DAYS[day - 1];
    }

    public static String getWeekDay(Calendar calendar) {
        return WEEK_DAYS[calendar.get(Calendar.DAY_OF_WEEK) - 1];
    }
} 